package com.yxq.mdt.app.modules.socialcontact.adapter;


import androidx.annotation.Nullable;

import com.alibaba.android.arouter.utils.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.orhanobut.hawk.Hawk;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.constant.SPKey;
import com.yxq.mdt.app.glide.GlideHelper;
import com.yxq.mdt.app.modules.personal.bean.MyPersonalBean;
import com.yxq.mdt.app.modules.socialcontact.bean.BrowseListBean;

import java.util.List;

public class SocialStateGiveListBrowseAdapter extends BaseQuickAdapter<BrowseListBean.ListBean, BaseViewHolder> {
    public SocialStateGiveListBrowseAdapter(int layoutResId, @Nullable List<BrowseListBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BrowseListBean.ListBean item) {
        MyPersonalBean myPersonalBean;
        myPersonalBean = Hawk.get(SPKey.SP_KEY_USER_MY_INFO);
        GlideHelper.setLoadRoundImage(mContext, item.getHeadimg(), 0, helper.getView(R.id.social_like_img));
        if (TextUtils.isEmpty(item.getConstellation())) {
            helper.setText(R.id.social_constellation_tv, "");
        } else {
            helper.setText(R.id.social_constellation_tv, item.getConstellation());
        }
        helper.setText(R.id.social_year_tv, item.getAge() + "岁");

        if (!TextUtils.isEmpty(item.getUserName())) {
            helper.setText(R.id.social_like_nike_name, item.getUserName());
        } else {
            helper.setText(R.id.social_like_nike_name, "yxq" + item.getCreateMan());
        }
        if (item.getSex() == 1) {
            helper.setImageResource(R.id.social_like_sex_img, R.mipmap.xb_nan);
        } else {
            helper.setImageResource(R.id.social_like_sex_img, R.mipmap.xb_nv);
        }
        if (TextUtils.isEmpty(item.getGeneration())) {
            helper.setText(R.id.social_like_introduce_tv, "");
        } else {
            helper.setText(R.id.social_like_introduce_tv, item.getGeneration());
        }
        if (item.getBrowseNum() == 0) {
            helper.setText(R.id.social_browse_tv, "");
        } else {
            helper.setText(R.id.social_browse_tv, "访问" + item.getBrowseNum() + "次");
        }
        if ((myPersonalBean.getUserId() + "").equals(item.getCreateMan())) {
            helper.setGone(R.id.social_attention_tv, false);
        } else {
            if (item.getConcern() != 0) {
                helper.setGone(R.id.social_attention_tv, false);
            } else {
                helper.setText(R.id.social_attention_tv, "关注");
            }
        }
        helper.addOnClickListener(R.id.social_attention_tv);
        if (TextUtils.isEmpty(item.getResidence())) {
            helper.setText(R.id.social_city_tv, "");
        } else {
            helper.setText(R.id.social_city_tv, item.getResidence());
        }
    }

}
